package com.yys.springcloud.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

import java.util.Date;

/**
 * @program: cloudalibaba2021
 * @description:
 * @author: Mr.Wu
 * @create: 2021-06-21 15:20
 **/
@Component
@Slf4j
@Order(0)  //注意添加这个
public class MGlobalFilter implements GlobalFilter {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        log.info("come in filter --------" + new Date());
        //可以在这里添加过滤规则,这里拦截到的是能匹配的路由路径
        return chain.filter(exchange);
    }
}
